package com.systemsjr.mpf.account;

import java.io.Serializable;

import android.net.Uri;

import com.systemsjr.mpf.db.AccountContentProvider;

public class Account implements Serializable, Cloneable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -542082672188786160L;

	public static final String ID = "_id";

	public static final String CODE = "CODE";

	public static final String ACCOUNT = "ACCOUNT";

	public static final String TABLE_NAME = "ACCOUNT";

	public static String ACCOUNT_LIST = "ACCOUNT_LIST";

	// THE CONTENT URI TO OUR PROVIDER
	public static final Uri CONTENT_URI = Uri.parse("content://"
			+ AccountContentProvider.AUTHORITY + "/account");

	// MIME TYPE FOR GROUP OF ACCOUNTS
	public static final String CONTENT_TYPE = "vnd.android.cursor.dir/com.systemsjr.mpf.account";

	// MIME TYPE FOR SINGLE ACCOUNT
	public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/com.systemsjr.mpf.account";

	public static final int CODE_PATH_POSITION = 1;
	
	public static final String[] PROJECTIONS = {Account.ID, Account.CODE, Account.ACCOUNT};

	private Long id;
	private String code, account;

	public Account() {
		id = 0L;
	}

	public Account(long id, String code, String account) {
		this.id = id;
		this.code = code;
		this.account = account;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public static String createTable() {

		return "CREATE TABLE " + TABLE_NAME + "(" + ID
				+ " INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL ," + CODE
				+ " TEXT NOT NULL  UNIQUE , " + ACCOUNT
				+ " TEXT NOT NULL  UNIQUE )";
	}
	
	public Account clone(){
		
		Account acc = new Account();
		
		acc.setId(id);
		acc.setAccount(account);
		acc.setCode(code);
		
		return acc;
	}
}
